﻿<?
include("../Common/Connect_DataBase.php");
$MaTheLoai=$_POST["cmbMaTheLoai"];
$TieuDe=$_POST["txtTieuDe"];
$TomTat=$_POST["txtTomTat"];
$NoiDung=$_POST["txtNoiDung"];
/*
if (isset($_POST['btnluu']))
{

        $target_path = "/TUVANNONGNGHIEP/Images_content/";
        $target_path = $target_path . basename( $_FILES['AnhMinhHoa']['name']); 
        if(move_uploaded_file($_FILES['AnhMinhHoa']['tmp_name'], $target_path)) 
        {
            echo "Tập tin ".  basename( $_FILES['AnhMinhHoa']['name'])." upload thành công";
        } 
        else
        {
            echo "Xảy ra lỗi khi upload file, mời thử lại";
        }
}
*/
if(isset($_FILES['AnhMinhHoa']['name']))
{
    move_uploaded_file($_FILES['AnhMinhHoa']['tmp_name'],"../Images_content/".$_FILES['AnhMinhHoa']['name']);
    $img= "Images_content/".$_FILES['AnhMinhHoa']['name'];
}

$TacGia=$_POST["txtTacGia"];
$NguonTin=$_POST["txtNguonTin"];
$NguoiNhapTin=$_POST["txtNguoiNhapTin"];
$NgayNhapTin=date("y/m/d h:i:s", time());
$TrangThai=$_POST["rdoTrangThai"];

$sql="INSERT INTO tintuc(MaTheLoai,TieuDe,TomTat,NoiDung,AnhMinhHoa,TacGia,NguonTin,NguoiNhapTin,NgayNhapTin,TrangThai) ";
$sql=$sql."VALUES('$MaTheLoai','$TieuDe','$TomTat','$NoiDung','$img','$TacGia','$NguonTin','$NguoiNhapTin','$NgayNhapTin','$TrangThai')";
echo $sql;
mysql_query($sql) or exit("Lỗi cập nhật");
echo "Đã cập nhật";

header("location:/TUVANNONGNGHIEP/Index.php");
?>
